local skel = fk.CreateSkill{
  name = "tea__shushen",
}
--local U = require "packages/utility/utility"
Fk:loadTranslationTable{
  ["tea__shushen"] = "淑慎",
  [":tea__shushen"] = "每回合限一次，当你获得牌后，你可以重铸任意张花色不同的牌，然后当前回合角色本回合下次使用与这些牌花色均不相同的牌后，你可以令其摸等量张牌。",
  ["@tea__shushen-turn"] = "淑慎",
  ["#tea__shushen-invoke"] = "淑慎：你可以重铸任意花色不同的牌张牌",
  ["#tea__shushen-drawcard"] = "淑慎：你可以令 %src 摸 %arg 张牌"
}
---@type TrigSkelSpec<DamageTrigFunc>
local shushen = {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name) and player:usedSkillTimes(skel.name, Player.HistoryTurn) == 0 then
      for _, move in ipairs(data) do
        if move.toArea == Card.PlayerHand and move.to == player then
          for _, info in ipairs(move.moveInfo) do
            return true
          end
        end
      end
    end
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local suc, dat = room:askToUseActiveSkill(player, {
      skill_name = "tea__shushen_choose_skill",
      prompt = "#tea__shushen-invoke"
    })
    if suc and dat and dat.cards then
      event:setCostData(self, { cards = dat.cards })
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local cards = event:getCostData(self).cards
    local to = room.current
    room:recastCard(cards, player, skel.name)
    if not player.dead then
      local suits = table.map(cards, function (id)
        local c = Fk:getCardById(id)
        return c:getSuitString(true)
      end)
      if to == room.current then
        room:setPlayerMark(player, "@tea__shushen-turn", suits)
        local current_event = room.logic:getCurrentEvent()
        room:setPlayerMark(player, "tea__shushen_event_id-turn", { current_event.id })
      end
    end
  end
}
---@type TrigSkelSpec<UseCardFunc>
local shushen_delay = {
  anim_type = "support",
  can_trigger = function (self, event, target, player, data)
    if player:hasSkill(skel.name) and player.room.current == target and player:getMark("@tea__shushen-turn") ~= 0 and data.card and not table.contains(player:getTableMark("@tea__shushen-turn"), data.card:getSuitString(true)) and #player:getTableMark("tea__shushen_event_id-turn") > 0 then
      local turn_id = player.room.logic:getCurrentEvent():findParent(GameEvent.Turn).id
      local current_id = player.room.logic:getCurrentEvent().id
      if turn_id and current_id then
        return player:getTableMark("tea__shushen_event_id-turn")[1] < current_id
      end
    end
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {
      skill_name = skel.name,
      prompt = "#tea__shushen-drawcard:".. player.room.current.id .. "::" .. #player:getTableMark("@tea__shushen-turn")
    })
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local num = #player:getTableMark("@tea__shushen-turn")
    room:setPlayerMark(player, "@tea__shushen-turn", 0)
    room:doIndicate(player, room.current)
    room.current:drawCards(num, skel.name)
  end
}
skel:addEffect(fk.AfterCardsMove, shushen)
skel:addEffect(fk.CardUseFinished, shushen_delay)
-- Fk.generals["mouxusheng"]:addSkill(skel.name)
return skel